﻿using Sidvall.Data;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Sidvall.Business
{
    public interface IDataPortalContext : ICriteria
    {
        string Resource { get; }
        string ResourceItemId { get; }
        string Action { get; }
        ISaveContext SaveContext { get; }
        Sidvall.Business.DataPortalResult Result { get; set; }
        object ResultValueItem { get; set; }
        IEnumerable ResultValueList { get; set; }
        IDataRowProvider ResultValueListProvider { get; set; }
        long? TotalRowCount { get; set; }
        bool Retry { get; }
        long RetryCount { get; }
        long MaxRetryCount { get; set; }
        bool ResultValueIsNewObject { get; }
        bool CopyOnSave { get; set; }
        Sidvall.Data.AcceptChangesSettings AcceptChangesSettings { get; }
        string StrategyContext { get; set; }
        System.Exception Exception { get; set; }
        System.Collections.ObjectModel.Collection<Task> Tasks { get; }
        object TaskContext { get; set; }
        Sidvall.Security.ResourceItemCollection AffectedResources { get; }
        IDataRowContextProvider ResourceItem { get; }
        IEnumerable<IDataRowContextProvider> ResourceItems { get; }
        ObjectParameterCollection ObjectParameters { get; }
        ISortItemsProvider SortItemsProvider { get; }
        IRelationItemsProvider RelationItemsProvider { get; }

        IDataPortalContext Copy(bool copyResult);
        Task DoTaskAsync();
        Task DoTaskAsync(bool throwException);
        DataRowState? GetDataRowState();
        DataRowState? GetDataRowState(IDataRowContextProvider provider);
        DataRowState? GetDataRowStateResolved();
        DataRowState? GetDataRowStateResolved(IDataRowContextProvider provider);
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
        IDataRowProvider GetResultValueListProviderResolved();
        void InitializeAffectedResources(IEnumerable<Sidvall.Security.ResourceItem> items);
        bool DoRetry();
        bool? DataRowStateIsDeleted();
        bool? DataRowStateIsDeleted(IDataRowContextProvider provider);
        bool? DataRowStateIsDirty();
        bool? DataRowStateIsDirty(IDataRowContextProvider provider);
        bool? DataRowStateIsSelfDirty();
        bool? DataRowStateIsSelfDirty(IDataRowContextProvider provider);
        bool? DataRowStateIsNew();
        bool? DataRowStateIsNew(IDataRowContextProvider provider);
        bool? DataRowStateIsUnchanged();
        bool? DataRowStateIsUnchanged(IDataRowContextProvider provider);
    }
}
